from typing import List


class Solution:
    @staticmethod
    def two_sum(self, nums: List[int], target: int) -> List[int]:
        if not nums or len(nums) < 2:
            return [-1, -1]
        d = {}
        for i, num in enumerate(nums):
            remain = target - num
            if remain in d:
                return[d[remain], i]
            d[num] = i
        return [-1, -1]


a = list(map(int, input().smit()))
t = int(input())
st = Solution()
print(st.two_sum(a, t))

